import { reactive, h } from 'vue'
import { _IFormEl, _IExtra } from '@/components/common/form/interface';
import { FormInstance, FormItemProps } from 'ant-design-vue';
import { useBaseStore } from '@/store'
import { educations, sexs, techLevels, isSel1, nationalitys, policys } from '@/common/model/base'
import dayjs, { Dayjs } from 'dayjs';
import { range } from '@/util/common'

const baseStore = useBaseStore()

// 禁止今天之前后的日期
const disabledDateAfter = (current: Dayjs) => {
  return current > dayjs().endOf('day');
}

const formatDate = (text: any): string => text ? dayjs(text).format('YYYY-MM-DD') : ''

// 格式枚举
const formatEnum = (text: any, enums: any[], mode: string = 'single') => {
  if(mode != 'single') {
    let infos = enums.filter(i => (text || '').split(',').includes(i.value + ''));
    return infos.map(i => i.label).join(',')
  }
  let info = enums.find(i => i.value == text);
  return info ? info['label'] : ''
}

// 基本信息相关字段
const formItemProps: FormItemProps & _IExtra = {
  labelWidth: '140px',
  colon: false
}
export const formEls: Array<_IFormEl> = reactive([
  { label: '部门', key: 'departmentId', col: { span: 8,}, element: 'select', 
    formItemProps: { ...formItemProps, required: true },
    componentProps: { options: baseStore.deptData, },
  },
  { label: '姓名', key: 'personnelName', col: { span: 8,}, element: 'input', 
    formItemProps: { ...formItemProps, required: true },
  },
  { label: '性别', key: 'gender', col: { span: 8 }, element: 'select', 
    formItemProps: { ...formItemProps, required: true },
    componentProps: { 
      options: baseStore.storesexs,
    }, 
  },
  { label: '民族', key: 'nation', col: { span: 8 }, element: 'select', 
    formItemProps: { ...formItemProps, required: true },
    componentProps: {
      options: baseStore.storenationalitys, showSearch: true
    }
  },
  { label: '身份证号码', key: 'idCardNo', col: { span: 8 }, element: 'input', 
    formItemProps: { ...formItemProps, required: true,
      rules: { 
        pattern: /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/, 
        message: '请输入正确的身份证号码!', 
        trigger: 'change' 
      }
    },
    componentProps: {
      maxlength: 18, showCount: true
    }
  },
  { label: '籍贯', key: 'nativePlace', col: { span: 8 }, element: 'input', 
    formItemProps: { ...formItemProps, required: true },
  },
  { label: '出生年月', key: 'dateOfBirth', col: { span: 8 }, element: 'datepicker', 
    formItemProps: { ...formItemProps, required: true },
    componentProps: {
      disabledDate: disabledDateAfter
    }
  },
  { label: '参加工作时间', key: 'employmentTime', col: { span: 8 }, element: 'datepicker', 
    formItemProps: { ...formItemProps, required: true,
      rules: [
        { type: 'date', max: dayjs().format('YYYY-MM-DD'), trigger: 'change'}
      ]
    },
    componentProps: {
      disabledDate: disabledDateAfter
    }
  },
  { label: '到单位工作年月', key: 'employmentYears', col: { span: 8 }, element: 'datepicker', 
    formItemProps: { ...formItemProps, required: true } ,
    componentProps: {
      picker: 'month', format: 'YYYY-MM', valueFormat: 'YYYY-MM-DD',
      disabledDate: (current: Dayjs) => {
        return current > dayjs().endOf('month');
      },
      placeholder: '含到院工作，正式签定合同年月或购买社保年月'
    }
  },
  { label: '政治面貌', key: 'politicalStatus', col: { span: 8 }, element: 'select', 
    formItemProps: { ...formItemProps, required: true } ,
    componentProps: { options: baseStore.storepolicys}, 
  },
  { label: '入党时间', key: 'groupTime', col: { span: 8 }, element: 'datepicker', 
    formItemProps: { ...formItemProps, required: false } ,
    componentProps: {
      disabledDate: disabledDateAfter
    }
  },
  { label: '最高学历', key: 'highestDegree', col: { span: 8 }, element: 'select', 
    formItemProps: { ...formItemProps, required: false } ,
    componentProps: { 
      disabled: true,
      options: baseStore.storeeducations
    }, 
  },
  { label: '职务', key: 'perJob', col: { span: 8 }, element: 'input', 
    formItemProps: { ...formItemProps, required: false } ,
    componentProps: { 
      disabled: true
    }, 
  },
  { label: '本人联系电话', key: 'perPhone', col: { span: 8 }, element: 'input', 
    formItemProps: { ...formItemProps, required: true } ,
    componentProps: {
      maxlength: 11, showCount: true
    }
  },
  // { label: '紧急联系人', key: 'key14', col: { span: 8 }, element: 'input', 
  //   formItemProps: { ...formItemProps, required: false } ,
  // },
  // { label: '紧急联系人电话', key: 'groupTime', col: { span: 8 }, element: 'input', 
  //   formItemProps: { ...formItemProps, required: false } ,
  // },
  // { label: '紧急联系关系', key: 'key19', col: { span: 8 }, element: 'input', 
  //   formItemProps: { ...formItemProps, required: false } ,
  // },
  { label: '户籍地址', key: 'domicileAddr', col: { span: 8 }, element: 'input', 
    formItemProps: { ...formItemProps, required: false } ,
  },
  { label: '年龄', key: 'perAge', col: { span: 8 }, element: 'number', 
    formItemProps: { 
      ...formItemProps, 
      required: false,
    },
    componentProps: {
      controls: false, max: 200, min: 1, precision: 0
    }
  },
  { label: '司龄', key: 'companyAge', col: { span: 8 }, element: 'number', 
    formItemProps: { ...formItemProps, required: false } ,
    componentProps: {
      disabled: true
    }
  },
  { label: '简历', key: 'curriculumVitae', col: { span: 24 }, element: 'textarea', 
    formItemProps: { ...formItemProps, required: false } ,
    componentProps: {
      maxLength: 200, showCount: true
    }
  },
])

// 学历相关列表
const educationItemProps: FormItemProps & _IExtra = {
  labelWidth: '100px',
  colon: false
}
export const educationFormCols =  reactive([
  { label: '学历形式', key: 'degreeForm', col: { span: 8,}, element: 'select', 
    formItemProps: { ...educationItemProps, required: true },
    componentProps: { 
      options: baseStore.storedegreeForm,
    },
  },
  { label: '学历', key: 'degreeName', col: { span: 8,}, element: 'select', 
    formItemProps: { ...educationItemProps, required: true },
    componentProps: { 
      options: baseStore.storeeducations,
    },
  },
  { label: '学历证书', key: 'degreeCertificate', col: { span: 8,}, element: 'select', 
    formItemProps: { ...educationItemProps, required: true },
    componentProps: { 
      options: baseStore.storedegreeCertificate, disabled: true
    },
  },
  { label: '专业结构类型', key: 'professionType', col: { span: 8,}, element: 'select', 
    formItemProps: { ...educationItemProps, required: true },
    componentProps: { 
      options: baseStore.storeprofessionTypes,
    },
  },
  { label: '取得的证书', key: 'certificate', col: { span: 8,}, element: 'selectC', 
    formItemProps: { ...educationItemProps, required: true },
    componentProps: { 
      mode: 'multiple',
      options: baseStore.storecertificate,
    },
  },
  { label: '毕业时间', key: 'graduationTime', col: { span: 8,}, element: 'datepicker', 
    formItemProps: { ...educationItemProps, required: true },
    componentProps: {
      disabledDate: disabledDateAfter
    }
  },
  { label: '毕业学校', key: 'school', col: { span: 8,}, element: 'input', 
    formItemProps: { ...educationItemProps, required: true },
  },
  { label: '毕业专业', key: 'profession', col: { span: 8,}, element: 'input', 
    formItemProps: { ...educationItemProps, required: true },
  },
  { label: '是否初始学历', key: 'isInitialDegree', col: { span: 8,}, element: 'select', 
    formItemProps: { ...educationItemProps, required: true },
    componentProps: { 
      options: isSel1(),
    },
  },
  { label: '是否最高学历', key: 'isHighestDegree', col: { span: 8,}, element: 'select', 
    formItemProps: { ...educationItemProps, required: true },
    componentProps: { 
      options: isSel1(),
    },
  },
  { label: '附件', key: 'appendixSaveVOList', col: { span: 24,}, element: 'file', 
    formItemProps: { ...educationItemProps, required: false },
    componentProps: {
      fileParams: {
        biztype: '2', bucket: 'PERSONNEL_BIZ_TYPE_DEGREE',
      }
    }
  },
])
export const educationCols =  reactive([
  { dataIndex: "index", title: "序号", width: 50, align: 'center',
    customRender: ({ index }) => index += 1
  },
  {dataIndex: 'degreeName', title: '学历', width: 100, align: 'center',
    customRender: ({ text }) => formatEnum(text, baseStore.storeeducations)
  },
  {dataIndex: 'degreeForm', title: '学历形式', width: 150,
    customRender: ({ text }) => formatEnum(text, baseStore.storedegreeForm)
  },
  {dataIndex: 'degreeCertificate', title: '学历证书', width: 150,
    customRender: ({ text }) => formatEnum(text, baseStore.storedegreeCertificate)
  },
  {dataIndex: 'professionType', title: '专业结构类型', minWidth: 150,
    customRender: ({ text }) => formatEnum(text, baseStore.storeprofessionTypes)
  },
  {dataIndex: 'certificate', title: '取得的证书', minWidth: 150,
    customRender: ({ text }) => formatEnum(text, baseStore.storecertificate, 'multiple')
  },
  {dataIndex: 'graduationTime', title: '毕业时间', minWidth: 150, 
    customRender: ({ text }) => formatDate(text)
  },
  {dataIndex: 'school', title: '毕业学校', minWidth: 150, },
  {dataIndex: 'profession', title: '毕业专业', minWidth: 150, },
  {dataIndex: 'isHighestDegree', title: '是否最高学历', width: 150, align: 'center', 
    customRender: ({ text }) => formatEnum(text, isSel1())
  },
  {dataIndex: 'isInitialDegree', title: '是否初始学历', width: 150, align: 'center',
    customRender: ({ text }) => formatEnum(text, isSel1())
  },
])

// 专业技术及职称相关字段
const technicalItemProps: FormItemProps & _IExtra = {
  labelWidth: '100px',
  colon: false
}
export const technicFormCols =  reactive([
  { label: '级别', key: 'technicalLevle', col: { span: 12,}, element: 'select', 
    formItemProps: { ...technicalItemProps, required: true },
    componentProps: { 
      options: baseStore.storetechLevels,
    },
  },
  { label: '职称专业', key: 'technicalProfession', col: { span: 12,}, element: 'input', 
    formItemProps: { ...technicalItemProps, required: true },
  },
  { label: '批准日期', key: 'tecApprovalDate', col: { span: 12,}, element: 'datepicker', 
    formItemProps: { ...technicalItemProps, required: true },
    componentProps: {
      disabledDate: disabledDateAfter
    }
  },
  { label: '证书颁发单位', key: 'tecUnit', col: { span: 12,}, element: 'input', 
    formItemProps: { ...technicalItemProps, required: true },
  },
  { label: '附件', key: 'appendixSaveVOList', col: { span: 24,}, element: 'file', 
    formItemProps: { ...technicalItemProps, required: false },
    componentProps: {
      fileParams: {
        biztype: '3', bucket: 'PERSONNEL_BIZ_TYPE_TECHNICAL',
      }
    }
  },
])
export const technicCols =  reactive([
  { dataIndex: "index", title: "序号", width: 50, align: 'center',
    customRender: ({ index }) => index += 1
  },
  {dataIndex: 'technicalLevle', title: '级别', width: 100,
    customRender: ({ text }) => formatEnum(text, baseStore.storetechLevels)
  },
  {dataIndex: 'technicalProfession', title: '职称专业', width: 100,},
  {dataIndex: 'tecApprovalDate', title: '批准日期', width: 100,
    customRender: ({ text }) => formatDate(text)
  },
  {dataIndex: 'tecUnit', title: '证书颁发单位', width: 100,},
])

// 其他证书相关字段
const certificateItemProps: FormItemProps & _IExtra = {
  labelWidth: '100px',
  colon: false
}
export const certificateFormCols =  reactive([
  { label: '证书名称', key: 'credentialName', col: { span: 8,}, element: 'input', 
    formItemProps: { ...certificateItemProps, required: true },
  },
  { label: '证书属性', key: 'credentialStats', col: { span: 8,}, element: 'select', 
    formItemProps: { ...certificateItemProps, required: true },
    componentProps: { 
      options: baseStore.storecredentialStats,
    },
  },
  { label: '证书颁发日期', key: 'creApprovalDate', col: { span: 8,}, element: 'datepicker', 
    formItemProps: { ...certificateItemProps, required: true },
    componentProps: {
      disabledDate: disabledDateAfter
    }
  },
  { label: '证书颁发单位', key: 'creUnit', col: { span: 8,}, element: 'input', 
    formItemProps: { ...certificateItemProps, required: true },
  },
  { label: '证书有效期', key: 'creValidity', col: { span: 8,}, element: 'input', 
    formItemProps: { ...certificateItemProps, required: true },
    componentProps: {
      mode: "tags",
      options: [{ label: '长期有效', value: '长期有效' }],
      placeholder: '可录入 长期有效、日期、天数'
      // showSearch: true
    }
  },
  { label: '附件', key: 'appendixSaveVOList', col: { span: 24,}, element: 'file', 
    formItemProps: { ...certificateItemProps, required: true },
    componentProps: {
      fileParams: {
        biztype: '4', bucket: 'PERSONNEL_BIZ_TYPE_CREDENTIALS',
      }
    }
  },
])
export const certificateCols =  reactive([
  { dataIndex: "index", title: "序号", width: 50, align: 'center',
    customRender: ({ index }) => index += 1
  },
  {dataIndex: 'credentialName', title: '证书名称', width: 100,},
  {dataIndex: 'credentialStats', title: '证书属性', width: 100,
    customRender: ({ text }) => formatEnum(text, baseStore.storecredentialStats)
  },
  {dataIndex: 'creApprovalDate', title: '证书颁发日期', width: 100,
    customRender: ({ text }) => (text || '').split(' ')[0]
  },
  {dataIndex: 'creUnit', title: '证书颁发单位', width: 100,},
  {dataIndex: 'creValidity', title: '证书有效期', width: 100,},
])

// 科研相关字段
const scientificItemProps: FormItemProps & _IExtra = {
  labelWidth: '80px',
  colon: false
}
export const scientificFormCols =  reactive([
  { label: '科研类型', key: 'scientificResearchType', col: { span: 24,}, element: 'select', 
    formItemProps: { ...scientificItemProps, required: true },
    componentProps: { 
      options: baseStore.storescientificResearchType
    },
  },
  { label: '取得时间', key: 'resApprovalDate', col: { span: 24,}, element: 'datepicker', 
    formItemProps: { ...scientificItemProps, required: true },
    componentProps: {
      disabledDate: disabledDateAfter
    }
  },
  { label: '备注', key: 'resRemark', col: { span: 24,}, element: 'textarea', 
    formItemProps: { ...scientificItemProps, required: false },
    componentProps: {
      maxLength: 255, showCount: true
    }
  },
  { label: '附件', key: 'appendixSaveVOList', col: { span: 24,}, element: 'file', 
    formItemProps: { ...scientificItemProps, required: false },
    componentProps: {
      fileParams: {
        biztype: '9', bucket: 'PERSONNEL_BIZ_TYPE_SCIENTIFIC_RESEARCH',
      }
    }
  },
])
export const scientificCols =  reactive([
  { dataIndex: "index", title: "序号", width: 50, align: 'center',
    customRender: ({ index }) => index += 1
  },
  {dataIndex: 'scientificResearchType', title: '科研类型', width: 150, align: 'center',
    customRender: ({ text }) => formatEnum(text, baseStore.storescientificResearchType)
  },
  {dataIndex: 'resApprovalDate', title: '取得时间', width: 150, align: 'center',
    customRender: ({ text }) => formatDate(text)
  },
  {dataIndex: 'resRemark', title: '备注', width: 150,},
])

// 奖励相关字段
const awardItemProps: FormItemProps & _IExtra = {
  labelWidth: '100px',
  colon: false
}
export const awardFormCols =  reactive([
  { label: '时间', key: 'commendDate', col: { span: 12,}, element: 'datepicker', 
    formItemProps: { ...awardItemProps, required: true },
    componentProps: {
      disabledDate: disabledDateAfter
    }
  },
  { label: '授予单位', key: 'commendUnit', col: { span: 12,}, element: 'input', 
    formItemProps: { ...awardItemProps, required: true },
  },
  { label: '表彰奖励名称', key: 'commendName', col: { span: 12,}, element: 'input', 
    formItemProps: { ...awardItemProps, required: true },
  },
  { label: '表彰奖励级别', key: 'commendLevel', col: { span: 12,}, element: 'select', 
    formItemProps: { ...awardItemProps, required: true },
    componentProps: { 
      options:  baseStore.storeawardLevels,
    },
  },
  { label: '奖项附件', key: 'appendixSaveVOList', col: { span: 24,}, element: 'file', 
    formItemProps: { ...awardItemProps, required: false },
    componentProps: {
      fileParams: {
        biztype: '6', bucket: 'PERSONNEL_BIZ_TYPE_COMMEND',
      }
    }
  },
])
export const awardCols =  reactive([
  { dataIndex: "index", title: "序号", width: 50, align: 'center',
    customRender: ({ index }) => index += 1
  },
  {dataIndex: 'commendDate', title: '时间', width: 150,
    customRender: ({ text }) => (text || '').split(' ')[0]
  },
  {dataIndex: 'commendUnit', title: '授予单位', width: 150,},
  {dataIndex: 'commendName', title: '表彰奖励名称', width: 150,},
  {dataIndex: 'commendLevel', title: '表彰奖励级别', width: 150,
    customRender: ({ text }) => formatEnum(text, baseStore.storeawardLevels)
  },
])

// 处分相关字段
const punishItemProps: FormItemProps & _IExtra = {
  labelWidth: '100px',
  colon: false
}
export const punishFormCols =  reactive([
  { label: '受处分时间', key: 'punishmentDate', col: { span: 8,}, element: 'datepicker', 
    formItemProps: { ...punishItemProps, required: true },
    componentProps: {
      disabledDate: disabledDateAfter
    }
  },
  { label: '处分单位', key: 'punUnit', col: { span: 8,}, element: 'input', 
    formItemProps: { ...punishItemProps, required: true },
  },
  { label: '处分名称', key: 'punishmentName', col: { span: 8,}, element: 'input', 
    formItemProps: { ...punishItemProps, required: true },
  },
  { label: '影响情况', key: 'influence', col: { span: 24,}, element: 'textarea', 
    formItemProps: { ...punishItemProps, required: false },
    componentProps: {
      maxLength: 200, showCount: true
    }
  },
  { label: '其他事项', key: 'rests', col: { span: 24,}, element: 'textarea', 
    formItemProps: { ...punishItemProps, required: false },
    componentProps: {
      maxLength: 200, showCount: true
    }
  },
  { label: '附件', key: 'appendixSaveVOList', col: { span: 24,}, element: 'file', 
    formItemProps: { ...punishItemProps, required: false },
    componentProps: {
      fileParams: {
        biztype: '7', bucket: 'PERSONNEL_BIZ_TYPE_PUNISHMENT',
      }
    }
  },
])
export const punishCols =  reactive([
  { dataIndex: "index", title: "序号", width: 50, align: 'center',
    customRender: ({ index }) => index += 1
  },
  {dataIndex: 'punishmentDate', title: '受处分时间', width: 150,
    customRender: ({ text }) => (text || '').split(' ')[0]
  },
  {dataIndex: 'punUnit', title: '处分单位', minWidth: 150,},
  {dataIndex: 'punishmentName', title: '处分名称', minWidth: 150,},
  {dataIndex: 'influence', title: '影响情况', minWidth: 150,},
  {dataIndex: 'rests', title: '其他事项', minWidth: 150,},
])

// 家庭成员相关字段
const familyItemProps: FormItemProps & _IExtra = {
  labelWidth: '100px',
  colon: false
}
export const familyFormCols =  reactive([
  { label: '家庭成员姓名', key: 'famName', col: { span: 8,}, element: 'input', 
    formItemProps: { ...familyItemProps, required: true },
  },
  { label: '与本人关系', key: 'famRelation', col: { span: 8,}, element: 'input', 
    formItemProps: { ...familyItemProps, required: true },
  },
  { label: '出生年月', key: 'famBirthDate', col: { span: 8,}, element: 'datepicker', 
    formItemProps: { ...familyItemProps, required: false },
    componentProps: {
      picker: 'month',
      format: 'YYYY-MM',
    }
  },
  { label: '政治面貌', key: 'famPolitcalStatus', col: { span: 8,}, element: 'select', 
    formItemProps: { ...familyItemProps, required: false },
    componentProps: { 
      options: baseStore.storepolicys,
    },
  },
  { label: '工作单位', key: 'famUnit', col: { span: 8,}, element: 'input', 
    formItemProps: { ...familyItemProps, required: false },
    componentProps: { 
      options: [],
    },
  },
  { label: '职务', key: 'famJob', col: { span: 8,}, element: 'input', 
    formItemProps: { ...familyItemProps, required: false },
    componentProps: { 
      options: [],
    },
  },
])
export const familyCols =  reactive([
  { dataIndex: "index", title: "序号", width: 50, align: 'center',
    customRender: ({ index }) => index += 1
  },
  {dataIndex: 'famName', title: '家庭成员姓名', minWidth: 150, element: 'input'},
  {dataIndex: 'famRelation', title: '关系', minWidth: 150, element: 'input'},
  {dataIndex: 'famBirthDate', title: '出生年月', minWidth: 150, element: 'datepicker',
    customRender: ({ text }) => text ? dayjs(text).format('YYYY-MM') : ''
  },
  {dataIndex: 'famPolitcalStatus', title: '政治面貌', minWidth: 150, element: 'input',},
  {dataIndex: 'famUnit', title: '工作单位', minWidth: 150, element: 'input'},
  {dataIndex: 'famJob', title: '职务', minWidth: 150, element: 'input'},
])

// 紧急联系人相关字段
const emergencyItemProps: FormItemProps & _IExtra = {
  labelWidth: '120px',
  colon: false
}
export const emergencyFormCols =  reactive([
  { label: '紧急联系人姓名', key: 'phoneName', col: { span: 8,}, element: 'input', 
    formItemProps: { ...emergencyItemProps, required: true },
  },
  { label: '关系', key: 'relation', col: { span: 8,}, element: 'input',
    formItemProps: { ...emergencyItemProps, required: true }, 
  },
  { label: '电话', key: 'phoneNub', col: { span: 8,}, element: 'input', 
    formItemProps: { ...emergencyItemProps, required: true },
    componentProps: {
      maxLength: 11, showCount: true
    }
  },
])
export const emergencyCols =  reactive([
  { dataIndex: "index", title: "序号", width: 50, align: 'center',
    customRender: ({ index }) => index += 1
  },
  {dataIndex: 'phoneName', title: '紧急联系人姓名', width: 150, element: 'input'},
  {dataIndex: 'relation', title: '关系', width: 150, element: 'input'},
  {dataIndex: 'phoneNub', title: '电话', width: 150, element: 'datepicker'},
])

// 职务相关字段
const jobItemProps: FormItemProps & _IExtra = {
  labelWidth: '100px',
  colon: false
}
export const jobFormCols =  reactive([
  { label: '职务', key: 'job', col: { span: 8,}, element: 'input', 
    formItemProps: { ...jobItemProps, required: true },
  },
  { label: '职务批准时间', key: 'approvalDate', col: { span: 8,}, element: 'datepicker', 
    formItemProps: { ...jobItemProps, required: true },
    componentProps: {
      disabledDate: disabledDateAfter
    }
  },
  { label: '是否当前职务', key: 'isPresentPosition', col: { span: 8,}, element: 'select', 
    formItemProps: { ...jobItemProps, required: true },
    componentProps: {
      options: isSel1()
    }
  },
  { label: '附件', key: 'appendixSaveVOList', col: { span: 24,}, element: 'file', 
    formItemProps: { ...jobItemProps, required: false },
    componentProps: {
      fileParams: {
        biztype: '5', bucket: 'PERSONNEL_BIZ_TYPE_JOB',
      }
    }
  },
])
export const jobCols =  reactive([
  { dataIndex: "index", title: "序号", width: 50, align: 'center',
    customRender: ({ index }) => index += 1
  },
  {dataIndex: 'job', title: '职务', width: 150},
  {dataIndex: 'isPresentPosition', title: '是否当前职务', width: 150,
    customRender: ({ text }) => formatEnum(text, isSel1())
  },
  {dataIndex: 'approvalDate', title: '职务批准时间', width: 150,
    customRender: ({ text }) => formatDate(text)
  },
])

// 年度考核
const yearCheckItemProps: FormItemProps & _IExtra = {
  labelWidth: '80px',
  colon: false
}
export const yearCheckFormCols =  reactive([
  { label: '考核年度', key: 'annualAssessmentDate', col: { span: 24,}, element: 'datepicker', 
    formItemProps: { ...yearCheckItemProps, required: true },
    componentProps: {
      picker: 'year', format: 'YYYY年', valueFormat: 'YYYY-MM-DD'
    }
  },
  { label: '等次', key: 'annualAssessmentLevle', col: { span: 24,}, element: 'select',
    formItemProps: { ...yearCheckItemProps, required: true }, 
    componentProps: {
      options: baseStore.storeannualAssessmentLevle
    }
  },
  { label: '年度考核表', key: 'appendixSaveVOList', col: { span: 24,}, element: 'file', 
    formItemProps: { ...yearCheckItemProps, required: false },
    componentProps: {
      fileParams: {
        biztype: '8', bucket: 'PERSONNEL_BIZ_TYPE_ANNUAL_ASSESMENT',
      }
    }
  },
])
export const yearCheckCols =  reactive([
  { dataIndex: "index", title: "序号", width: 50, align: 'center',
    customRender: ({ index }) => index += 1
  },
  {dataIndex: 'annualAssessmentDate', title: '考核年度', width: 150,
    customRender: ({ text }) => text ? dayjs(text).format('YYYY') : ''
  },
  {dataIndex: 'annualAssessmentLevle', title: '等次', width: 150, 
    customRender: ({ text }) => formatEnum(text, baseStore.storeannualAssessmentLevle)
  },
  // {dataIndex: 'appendixSaveVOList', title: '年度考核表', width: 150, },
])

// 受聘专家情况
const expertItemProps: FormItemProps & _IExtra = {
  labelWidth: '100px',
  colon: false
}
export const expertFormCols = reactive([
  { label: '专家名称', key: 'expertName', col: { span: 12,}, element: 'input', 
    formItemProps: { ...expertItemProps, required: true },
  },
  { label: '专家组别', key: 'expertGroup', col: { span: 12,}, element: 'select', 
    formItemProps: { ...expertItemProps, required: true },
    componentProps: { 
      options: baseStore.storeexpertGroup
    },
  },
  { label: '聘用单位', key: 'expertUnit', col: { span: 12 }, element: 'input', 
    formItemProps: { ...expertItemProps, required: true },
  },
  { label: '聘用开始时间', key: 'expBeginDate', col: { span: 12 }, element: 'datepicker', 
    formItemProps: { ...expertItemProps, required: true },
  },
  { label: '聘用结束时间', key: 'expEndDate', col: { span: 12 }, element: 'datepicker', 
    formItemProps: { ...expertItemProps, required: true },
  },
])
export const expertCols =  reactive([
  { dataIndex: "index", title: "序号", width: 50, align: 'center',
    customRender: ({ index }) => index += 1
  },
  {dataIndex: 'expertName', title: '专家名称', width: 150,},
  {dataIndex: 'expertGroup', title: '专家组别', width: 150,
    customRender: ({ text }) =>  formatEnum(text, baseStore.storeexpertGroup)
  },
  {dataIndex: 'expertUnit', title: '聘用单位', width: 150,},
  {dataIndex: 'expBeginDate', title: '聘用开始时间', width: 150,
    customRender: ({ text }) => formatDate(text)
  },
  {dataIndex: 'expEndDate', title: '聘用截止时间', width: 150, 
    customRender: ({ text }) => formatDate(text)
  },
])

// 人事合同
const contractItemProps: FormItemProps & _IExtra = {
  labelWidth: '100px',
  colon: false
}
export const contractFormCols =  reactive([
  { label: '合同签订单位', key: 'conUnit', col: { span: 24,}, element: 'input', 
    formItemProps: { ...contractItemProps, required: true },
  },
  { label: '开始时间', key: 'conBeginDate', col: { span: 12 }, element: 'datepicker', 
    formItemProps: { ...contractItemProps, required: true },
    componentProps: {
      placeholder: '最近的劳动合同开始时间'
    }
  },
  { label: '结束时间', key: 'conEndDate', col: { span: 12 }, element: 'datepicker', 
    formItemProps: { ...contractItemProps, required: true },
    componentProps: {
      placeholder: '最近的劳动合同结束时间'
    }
  },
  { label: '合同附件', key: 'appendixSaveVOList', col: { span: 24 }, element: 'file', 
    formItemProps: { ...contractItemProps, required: true } ,
    componentProps: {
      fileParams: {
        biztype: '1', bucket: 'PERSONNEL_BIZ_TYPE_CONTRACT',
      }
    }
  },
])
export const contractCols =  reactive([
  { dataIndex: "index", title: "序号", width: 50, align: 'center',
    customRender: ({ index }) => index += 1
  },
  { dataIndex: "conUnit", title: "合同签订单位", width: 100, align: 'center' },
  // { dataIndex: "key4", title: "合同类型", width: 100, align: 'center' },
  { dataIndex: "conBeginDate", title: "合同开始日期", width: 100, align: 'center',
    customRender: ({ text }) => (text || '').split(' ')[0]
  },
  { dataIndex: "conEndDate", title: "合同到期日期", width: 100, align: 'center',
    customRender: ({ text }) => (text || '').split(' ')[0]
  },
  { dataIndex: "daynum", title: "剩余天数", width: 100, align: 'center',
    customRender: ({ record }) => {
      return dayjs(record['conEndDate']).diff(dayjs(), 'day') + 1 + '天'
    }
  },
])

// 外派
const outSendItemProps: FormItemProps & _IExtra = {
  labelWidth: '100px',
  colon: false
}
export const outSendFormCols =  reactive([
  { label: '派遣情况', key: 'dispatchCause', col: { span: 24,}, element: 'textarea', 
    formItemProps: { ...outSendItemProps, required: true },
    componentProps: {
      maxlength: 200, showCount: true,
      palceholder: '含续/转、借用、专班、项目组、挂职'
    }
  },
  // { label: '开始时间', key: 'beginDate', col: { span: 12 }, element: 'datepicker', hide: true,
  //   formItemProps: { ...outSendItemProps, required: true },
  //   componentProps: {
  //   }
  // },
  // { label: '结束时间', key: 'endDate', col: { span: 12 }, element: 'datepicker', hide: true,
  //   formItemProps: { ...outSendItemProps, required: true },
  //   componentProps: {
  //   }
  // },
  // { label: '天数', key: 'number', col: { span: 12 }, element: 'number',  hide: true,
  //   formItemProps: { ...outSendItemProps, required: true },
  //   componentProps: {
  //     disabled: true
  //   }
  // },
  // { label: '任务安排单位', key: 'sourceUnit', col: { span: 12,}, element: 'input',  hide: true,
  //   formItemProps: { ...outSendItemProps, required: true },
  // },
  // { label: '拟派往单位', key: 'destinationUnit', col: { span: 12,}, element: 'input',  hide: true,
  //   formItemProps: { ...outSendItemProps, required: true },
  // },
])
export const outSendCols =  reactive([
  { dataIndex: "index", title: "序号", width: 50, align: 'center',
    customRender: ({ index }) => index += 1
  },
  // { dataIndex: "beginDate", title: "派遣开始日期", width: 100, align: 'center',
  //   customRender: ({ text }) => (text || '').split(' ')[0]
  // },
  // { dataIndex: "endDate", title: "派遣结束日期", width: 100, align: 'center',
  //   customRender: ({ text }) => (text || '').split(' ')[0]
  // },
  // { dataIndex: "number", title: "派遣天数", width: 100, align: 'center' },
  // { dataIndex: "sourceUnit", title: "任务安排单位", width: 100, align: 'center' },
  // { dataIndex: "destinationUnit", title: "拟派往单位", width: 100, align: 'center' },
  { dataIndex: "dispatchCause", title: "派遣情况", minWidth: 100, },
  // { dataIndex: "key8", title: "派遣性质", width: 100, align: 'center' },
  // { dataIndex: "key9", title: "回司日期", width: 100, align: 'center' },
  // { dataIndex: "do", title: "查看备案信息", width: 100, align: 'center',
  //   customRender: ({  }) => {
  //     return h(Space, { style: { cursor: 'pointer'}, size: 18}, [
  //       h(LogoutOutlined, { title: '派遣信息', style: { color: '#1890ff'}, onClick: () => showBackupOut.value = true }),
  //       h(LoginOutlined, { title: '回司信息', style: { color: '#1890ff'}, onClick: () => showBackupIn.value = true }),
  //     ])
  //   }
  // },
])

// 分类数据,列表展现
export const collapses = reactive([
  { label: '基本信息', activeKey: 'base', els: formEls, value: '', type: 'form',
    props: { 
      showArrow: false, collapsible: 'disabled'
    }
  },
  { label: '学历', activeKey: 'education', els: educationCols, editForm: educationFormCols, value: '', type: 'table', canEdit: true },
  { label: '专业技术职称', activeKey: 'technical', els: technicCols, editForm: technicFormCols, value: '', type: 'table', canEdit: true  },
  { label: '其他资格证书', activeKey: 'certificate', els: certificateCols, editForm: certificateFormCols, value: '', type: 'table', canEdit: true  },
  { label: '受聘专家情况', activeKey: 'expert', els: expertCols, editForm: expertFormCols, value: '', type: 'table', canEdit: true  },
  { label: '职务信息', activeKey: 'job', els: jobCols, editForm: jobFormCols, value: '', type: 'table', canEdit: true  },
  { label: '合同信息', activeKey: 'contract', els: contractCols, editForm: contractFormCols, value: '', type: 'table', canEdit: true  },
  { label: '受表彰奖励情况', activeKey: 'award', els: awardCols, editForm: awardFormCols, value: '', type: 'table', canEdit: true  },
  { label: '受处分情况', activeKey: 'punish', els: punishCols, editForm: punishFormCols, value: '', type: 'table', canEdit: true  },
  { label: '派遣信息', activeKey: 'outsend', els: outSendCols, editForm: outSendFormCols, value: '', type: 'table', canEdit: true  },
  { label: '年度考核情况', activeKey: 'yearcheck', els: yearCheckCols, editForm: yearCheckFormCols, value: '', type: 'table', canEdit: true  },
  { label: '家庭主要成员及社会关系', activeKey: 'family', els: familyCols, editForm: familyFormCols, value: '', type: 'table', canEdit: true  },
  { label: '紧急联系人', activeKey: 'emergencyLink', els: emergencyCols, editForm: emergencyFormCols, value: '', type: 'table', canEdit: true  },
  { label: '科研情况', activeKey: 'scientific', els: scientificCols, editForm: scientificFormCols, value: '', type: 'table', canEdit: true  },
])